package com.qinyi.system.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.qinyi.common.constant.SecurityConstants;
import com.qinyi.system.domin.SysUser;
import com.qinyi.system.mapper.SysUserMapper;
import com.qinyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

/**
 * @author wangan on 2019/5/31
 * @description
 */
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {

	@Autowired
	private RedisTemplate redisTemplate;

	@Override
	public void saveImageCode(String randomStr, String text) {
		redisTemplate.opsForValue().set(SecurityConstants.DEFAULT_CODE_KEY + randomStr, text,
				SecurityConstants.DEFAULT_IMAGE_EXPIRE, TimeUnit.SECONDS);
	}

	@Override
	public SysUser selectUserByLoginName(String username) {
		return baseMapper.selectUserByLoginName(username);
	}

	@Override
	public int updateUserInfo(SysUser user) {
		return baseMapper.updateUserInfo(user);
	}
}
